﻿IF  EXISTS (SELECT * FROM sys.objects 
	WHERE object_id = OBJECT_ID(N'[dbo].[usp_MethodAudit_insert]') 
	AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[usp_MethodAudit_insert]
GO
create proc [dbo].[usp_MethodAudit_insert]
@Id  uniqueidentifier, 
@Module varchar(512),
@ClassName varchar(512),
@Method varchar(256),
@Created datetime = null,
@Application uniqueidentifier  = null,
@Solution varchar(256) = null,
@Operation uniqueidentifier 
as
insert into MethodAudits(Id,Solution, Module, ClassName, Method, Created, [Application], Operation) values( @Id, @Solution,  @Module, @ClassName, @Method, @Created, @Application,@Operation)
GO
IF  EXISTS (SELECT * FROM sys.objects 
	WHERE object_id = OBJECT_ID(N'[dbo].[usp_MethodAudit_delete]') 
	AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[usp_MethodAudit_delete]
GO
create proc [dbo].[usp_MethodAudit_delete]
@Id  uniqueidentifier  
as
delete from MethodAudits where Id = @Id
GO
IF  EXISTS (SELECT * FROM sys.objects 
	WHERE object_id = OBJECT_ID(N'[dbo].[usp_MethodAudit_update]') 
	AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[usp_MethodAudit_update]
GO
create proc [dbo].[usp_MethodAudit_update]
@Id  uniqueidentifier,
@Method varchar(256)
as
update MethodAudits set Method =@Method where Id = @Id 
GO
IF  EXISTS (SELECT * FROM sys.objects 
	WHERE object_id = OBJECT_ID(N'[dbo].[usp_MethodAudit_getone]') 
	AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[usp_MethodAudit_getone]
GO
create proc [dbo].[usp_MethodAudit_getone]
@Id  uniqueidentifier
as
	select * from MethodAudits where Id = @Id 
GO
IF  EXISTS (SELECT * FROM sys.objects 
	WHERE object_id = OBJECT_ID(N'[dbo].[usp_MethodAudit_getall]') 
	AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[usp_MethodAudit_getall]
GO
create proc [dbo].[usp_MethodAudit_getall]
as
	select * from MethodAudits 
GO
IF  EXISTS (SELECT * FROM sys.objects 
	WHERE object_id = OBJECT_ID(N'[dbo].[usp_MethodAudit_getbySolutionModuleClassNameMethod]') 
	AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[usp_MethodAudit_getbySolutionModuleClassNameMethod]
GO
create proc usp_MethodAudit_getbySolutionModuleClassNameMethod
@solution varchar(256) ,
@Module varchar(512),
@ClassName varchar(512),
@Method varchar(256)
as
select *  from MethodAudits 
where Solution=@solution and Module =@Module and ClassName = @ClassName and Method = @Method
order by Created asc
go